package com.atguigu.srb.core.controller.admin;
import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.vo.BorrowInfoApprovalVo;
import com.atguigu.srb.core.entity.vo.BorrowInfoVo;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
@Api(tags = "借款申请管理模块")
public class AdminBorrowInfoController {
    @Resource
    BorrowInfoService borrowInfoService;
    @GetMapping("/list")
    @ApiOperation("查询所有的借款申请")
    public R getBorrowLists(){
        List<BorrowInfoVo> lists = borrowInfoService.getLists();
        return R.ok().data("items",lists);
    }
    @ApiOperation("根据id查询借款申请的详细信息")
    @GetMapping("/detail/{id}")
    public R getBorrowDetailById(@PathVariable("id")Long id){
        //这个地方的id指的是borrowInfo的id
        Map<String,Object> map = borrowInfoService.getBorrowDetail(id);
        return R.ok().data(map);
    }
    @ApiOperation("借款审批方法")
    @PostMapping("approval")
    public R approval(@RequestBody BorrowInfoApprovalVo borrowInfoApprovalVo){
        borrowInfoService.approval(borrowInfoApprovalVo);
        return R.ok();
    }
}

